package com.yan.job;

import com.yan.domainjob.Man;
import com.yan.domainjob.Person;
import com.yan.domainjob.Woman;

public class Test1 {
    public static void meeting(Person... ps){
        for (int i = 0; i < ps.length; i++) {
                ps[i].eat();
                ps[i].toilet();
            //instanceof是Java中的二元运算符，左边是对象，右边是类；当对象是右边类或子类所创建对象时，返回true；否则，返回false。
                if(ps[i] instanceof Man){
                    ((Man) ps[i]).smoke();
                }else {
                    ((Woman) ps[i]).makeup();
                }
            System.out.println("-------------------");
        }
    }

    public static void main(String[] args) {
        meeting(new Man() , new Woman() , new Man() , new Woman());
    }
}
